import request from '@/utils/request';
import type{DeptQuery,DeptVO,DeptForm} from  './model';
import type { OptionType } from 'element-plus/es/components/select-v2/src/select.types.mjs';

/**
   * 部门树形表格
   *
   * @param queryParams
   */
export function getList(queryParams?:DeptQuery){
    return request<any,DeptVO[]>({
        url:'/api/v1/dept',
        method:'get',
        params:queryParams,
        headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        }
    })
}

/**
   * 部门下拉列表
   */
export function getOptions(){
    return request<any,OptionType[]>({
        url:"/api/v1/dept/options",
        method:"get",
        headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        }
    })
} 

/**
   * 获取部门详情
   *
   * @param id
   */
export function getFormData(id:number){
    return request<any,DeptForm>({
        url:"/api/v1/dept/" + id + "/form",
        method:"get",
        headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        }
    })
} 

/**
   * 新增部门
   *
   * @param data
   */
export function add(data:DeptForm){
    return request({
        url:"/api/v1/dept",
        method:"post",
        data:data,
        headers:{
            "Content-Type":"application/json"
        }
    })
} 

/**
   *  修改部门
   *
   * @param id
   * @param data
   */
export function update(id:number,data:DeptForm){
    return request({
        url:"/api/v1/dept/" + id,
        method:"put",
        data:data,
        headers:{
            "Content-Type":"application/json"
        }
    })
} 
/**
   * 删除部门
   *
   * @param ids
   */
export function deleteByIds(ids:string){
    return request({
        url:"/api/v1/dept/" + ids,
        method:"delete",
        headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        }
    })
} 
